<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>循环结构</title>
	</head>
	<body>
		<div id="app">
			<!-- 1.循环数组 注意事项:循环时最好指定key 标识循环的内容 -->
			<h3 v-for="item in hobbys" v-text="item" :key="item"></h3>
			<!-- 2.带下标的循环遍历语法 -->
			<h3 v-for="(item,index) in hobbys" v-text="item" :key="index"></h3>
			<!-- 3.循环遍历对象 -->
			<div v-for="user in userList" :key="user.id">
				<span v-text="user.id"></span>
				<span v-text="user.name"></span>
			</div>
		</div>
		<script src="../js/vue.js"></script>
		<script>
			const app = new Vue({
				el:"#app",
				data:{
					// 一般采用数组形式保存多个数据
					hobbys:['打游戏','敲代码','喝水','水王八'],
					userList:[{
						id:100,
						name:'孙尚香',
					},{
						id:200,
						name:'甄姬',
					},{
						id:300,
						name:'貂蝉',
					}]
				}
			})
		</script>
	</body>
</html>
